package com.arron.principle.inversion.improve;

public class DependencyInversion {
    public static void main(String[] args) {
        //客户端无需改变
        Person person =new Person();
        person.receive(new Email());
        person.receive(new Weixin());
    }
}

//接口定义
interface IReceiver{
    String getInfo();
}

class Email implements IReceiver{
    public String getInfo(){
        return "email info：hello world.";
    }
}

class Weixin implements IReceiver{
    public String getInfo() {
        return "Wechat :你好。";
    }
}

class Person{
    //对接口的依赖
    public void receive(IReceiver receiver){
        System.out.println(receiver.getInfo());
    }
}
